#--===auroraplugin===--
#  -*- coding: utf-8 -*-
#  aurora plugin
#  dns_plugin.py
#  edited by kf (kforkingfisher@gmail/nimbuzz.com)
#############################################
###########    ##    #####         ##########
############  ###  #######  #####  ##########
############  ##  ########  #################
############  #  #########  #################
############    ##########  #### ############
############   ###########       ############
############    ##########  #### ############
############  #  #########  #################
############  ##   #######  #################
############  ###   ######  #################
###########    ##     ###    ################
#############################################
###########KFORKINGFISHER@GMAIL.COM##########
##########KFORKINGFISHER@NIMBUZZ.COM#########
#############################################

import socket

def dns_query(query):
	try:
		int(query[-1])
	except ValueError:
		try:
			(hostname, aliaslist, ipaddrlist) = socket.gethostbyname_ex(query)
			return u', '.join(ipaddrlist)
		except socket.gaierror:
			return u'i did not find :('
	else:
		try:
			(hostname, aliaslist, ipaddrlist) = socket.gethostbyaddr(query)
		except socket.herror:
			return u'sorry me dhund nahi payi :( :-('
		return hostname + ' ' + string.join(aliaslist) + ' ' + string.join(aliaslist)

def handler_dns_dns(type, source, parameters):
	if parameters.strip():
		result = dns_query(parameters)
		reply(type, source, result)
	else:
		reply(type, source, u'what is it?')
def handler_abd(type, source, parameters):
       replies = [u'abd is my creator']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_masum(type, source, parameters):
       replies = [u'masum is my owner']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_abdullah(type, source, parameters):
       replies = [u'abdullah ji mere malik hai']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_uhu(type, source, parameters):
       replies = [u'me uhu ka gulaam hu ']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_unsmart(type, source, parameters):
       replies = [u'un$mart to mere malik hai :-P ']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_tameene(type, source, parameters):
       replies = [u'tameene to mere malik hai :-P ']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_tamina(type, source, parameters):
       replies = [u'tamina kf :$ kaha hai kf ? :-P']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_tamine(type, source, parameters):
       replies = [u'tamina kf :$ kaha hai kf ? :-P']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_kameena(type, source, parameters):
       replies = [u'kameene to mere malik hai :-P ']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_kameene(type, source, parameters):
       replies = [u'kameene to mere malik hai :-P ']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_kamina(type, source, parameters):
       replies = [u'kamina kf :$ kaha hai kf ? :-P']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_kamine(type, source, parameters):
       replies = [u'kamina kf :$ kaha hai kf ? :-P']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_maker_(type, source, parameters):
       replies = [u'aurora bot is property of \nABDULLAH \ncontact him at:\nabd~ksa@nimbuzz.com \n0nl00ker@nimbuzz.com \namasum94@@gmail.com']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)

def handler_bangla_(type, source, parameters):
       replies = [u'অররা বট তৈরি করেছেন \nআব্দুল্লাহ \ncontact him at : \nabd~ksa@nimbuzz.com \n0nl00ker@nimbuzz.com \namasum94@gmail.com ']
       balas = random.choice(replies)
       if type == 'public':
               if source[1]:
                       reply(type, source, balas)
       elif type == 'private':
               reply(type, source, balas)


register_command_handler(handler_dns_dns, 'dns', ['info','all'], 10, 'Shows an answer from DNS for a certain host or IP of address.', 'dns <host/IP>', ['dns server.tld', 'dns 127.0.0.1'])
register_command_handler(handler_abd, 'abd', ['new'], 0, '', '', [''])
register_command_handler(handler_masum, 'masum', ['new'], 0, '', '', [''])
register_command_handler(handler_abdullah, 'abdullah', ['new'], 0, '', '', [''])
register_command_handler(handler_uhu, 'uhu', ['new'], 0, '', '', [''])
register_command_handler(handler_unsmart, 'unsmart', ['new'], 0, '', '', [''])
register_command_handler(handler_tameene, 'tameene', ['new'], 0, '', '', [''])
register_command_handler(handler_tamina, 'tamina', ['new'], 0, '', '', [''])
register_command_handler(handler_tamine, 'tamine', ['new'], 0, '', '', [''])
register_command_handler(handler_kameena, 'kameena', ['new'], 0, '', '', [''])
register_command_handler(handler_kameene, 'kameene', ['new'], 0, '', '', [''])
register_command_handler(handler_kamina, 'kamina', ['new'], 0, '', '', [''])
register_command_handler(handler_kamine, 'kamine', ['new'], 0, '', '', [''])
register_command_handler(handler_maker_, 'maker', ['new'], 0, '', '', [''])
register_command_handler(handler_maker_, 'owner', ['new'], 0, '', '', [''])
register_command_handler(handler_maker_, 'malik', ['new'], 0, '', '', [''])
register_command_handler(handler_maker_, 'aurora', ['new'], 0, '', '', [''])
register_command_handler(handler_bangla_, 'bangla', ['new'], 0, '', '', [''])

